package com.rickpan.dto.request;

import com.rickpan.entity.Team;
import io.swagger.v3.oas.annotations.media.Schema;
import jakarta.validation.constraints.Max;
import jakarta.validation.constraints.Min;
import jakarta.validation.constraints.NotNull;

import java.util.List;

/**
 * 团队设置请求DTO
 */
@Schema(description = "团队设置请求")
public class TeamSettingsRequest {

    @Schema(description = "团队可见性", example = "INTERNAL", allowableValues = {"PUBLIC", "INTERNAL", "PRIVATE"})
    @NotNull(message = "团队可见性不能为空")
    private Team.Visibility visibility;

    @Schema(description = "加入方式", example = "INVITE_ONLY", allowableValues = {"INVITE_ONLY", "REQUEST", "OPEN"})
    @NotNull(message = "加入方式不能为空")
    private Team.JoinMethod joinMethod;

    @Schema(description = "默认成员权限", example = "[\"VIEW_MEMBERS\", \"INVITE_MEMBERS\"]")
    private List<String> defaultPermissions;

    @Schema(description = "是否启用通知", example = "true")
    private Boolean enableNotifications = true;

    @Schema(description = "通知类型", example = "[\"MEMBER_JOIN\", \"MEMBER_LEAVE\"]")
    private List<String> notificationTypes;

    @Schema(description = "是否要求两步验证", example = "false")
    private Boolean requireTwoFactor = false;

    @Schema(description = "会话超时时间(小时)", example = "24", minimum = "1", maximum = "168")
    @Min(value = 1, message = "会话超时时间最少1小时")
    @Max(value = 168, message = "会话超时时间最多168小时")
    private Integer sessionTimeout = 24;

    @Schema(description = "是否允许成员邀请其他成员", example = "false")
    private Boolean allowMemberInvite = false;

    @Schema(description = "是否允许成员创建项目", example = "false")
    private Boolean allowMemberCreateProject = false;

    @Schema(description = "是否允许成员管理文件", example = "false")
    private Boolean allowMemberManageFiles = false;

    // 构造函数
    public TeamSettingsRequest() {}

    public TeamSettingsRequest(Team.Visibility visibility, Team.JoinMethod joinMethod) {
        this.visibility = visibility;
        this.joinMethod = joinMethod;
    }

    // Getter和Setter方法
    public Team.Visibility getVisibility() {
        return visibility;
    }

    public void setVisibility(Team.Visibility visibility) {
        this.visibility = visibility;
    }

    public Team.JoinMethod getJoinMethod() {
        return joinMethod;
    }

    public void setJoinMethod(Team.JoinMethod joinMethod) {
        this.joinMethod = joinMethod;
    }

    public List<String> getDefaultPermissions() {
        return defaultPermissions;
    }

    public void setDefaultPermissions(List<String> defaultPermissions) {
        this.defaultPermissions = defaultPermissions;
    }

    public Boolean getEnableNotifications() {
        return enableNotifications;
    }

    public void setEnableNotifications(Boolean enableNotifications) {
        this.enableNotifications = enableNotifications;
    }

    public List<String> getNotificationTypes() {
        return notificationTypes;
    }

    public void setNotificationTypes(List<String> notificationTypes) {
        this.notificationTypes = notificationTypes;
    }

    public Boolean getRequireTwoFactor() {
        return requireTwoFactor;
    }

    public void setRequireTwoFactor(Boolean requireTwoFactor) {
        this.requireTwoFactor = requireTwoFactor;
    }

    public Integer getSessionTimeout() {
        return sessionTimeout;
    }

    public void setSessionTimeout(Integer sessionTimeout) {
        this.sessionTimeout = sessionTimeout;
    }

    public Boolean getAllowMemberInvite() {
        return allowMemberInvite;
    }

    public void setAllowMemberInvite(Boolean allowMemberInvite) {
        this.allowMemberInvite = allowMemberInvite;
    }

    public Boolean getAllowMemberCreateProject() {
        return allowMemberCreateProject;
    }

    public void setAllowMemberCreateProject(Boolean allowMemberCreateProject) {
        this.allowMemberCreateProject = allowMemberCreateProject;
    }

    public Boolean getAllowMemberManageFiles() {
        return allowMemberManageFiles;
    }

    public void setAllowMemberManageFiles(Boolean allowMemberManageFiles) {
        this.allowMemberManageFiles = allowMemberManageFiles;
    }

    @Override
    public String toString() {
        return "TeamSettingsRequest{" +
                "visibility=" + visibility +
                ", joinMethod=" + joinMethod +
                ", defaultPermissions=" + defaultPermissions +
                ", enableNotifications=" + enableNotifications +
                ", notificationTypes=" + notificationTypes +
                ", requireTwoFactor=" + requireTwoFactor +
                ", sessionTimeout=" + sessionTimeout +
                ", allowMemberInvite=" + allowMemberInvite +
                ", allowMemberCreateProject=" + allowMemberCreateProject +
                ", allowMemberManageFiles=" + allowMemberManageFiles +
                '}';
    }
}
